home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Infrequent use of do while, C Idioms
- Date: Sat, 13 Jan 96 15:05:47 GMT
- Organization: none
- Distribution: world
- Message-ID: <821545547snz@genesis.demon.co.uk>
- References: <49slsq$10l@panix2.panix.com> <4a5pk6$pvd@ixnews6.ix.netcom.com> <1995Dec7.154222.9354@lamont.ldgo.columbia.edu> <1996Jan2.150509@hsun13.hou281.chevron.com> <4d2vhq$rir@castle.nando.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4d2vhq$rir@castle.nando.net> validatr@nando.net "validatr" writes:
-
- >Actually the do while command is quite useful if you want to execute some
- >code at least once and then conditionally. This saves you from writing
- >something like:
- >
- >perform x
- >while(condition) {perform x}
- >
- >which is something we all have seen. It is less code and still
- >completely understandable to do the following:
- >
- >do {perform x} while (condition)
-
- In fact it is IMHO clearer to do it this way. do-while makes sense when the
- condition is based on information read/calculated in the loop body and
- simply has no meaning before the loop body is executed.
-
- >I like the command and have used it frequently.
-
- Likewise, except that C doesn't have commands, it has statements (e.g.
- do-while), expressions and functions.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-